<script lang="ts" setup>
import { ref } from 'vue'
import { Search } from '@element-plus/icons-vue'
const searchText = ref('')
const emit = defineEmits(['add', 'search'])
const props = defineProps({
  addBtn: {
    type: Boolean,
    default: true
  }
})
</script>
<template>
  <div class="wrap">
    <div class="left">
      <el-input v-model="searchText" @change="emit('search', searchText)" style="width: 240px" placeholder="搜索..." :prefix-icon="Search" />
      <slot name="left"></slot>
    </div>
    <div class="right">
      <slot name="right"></slot>
      <el-button type="success" v-if="addBtn" @click="$emit('add')">新增</el-button>
    </div>
  </div>
</template>

<style scoped>
.wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}
</style>
